package controllers

import (
	"github.com/gin-contrib/sessions"
	"github.com/gin-gonic/gin"
	"github.com/google/wire"

	"gitee.com/cjf8134/bbs_serve/internal/pkg/session"
	"gitee.com/cjf8134/bbs_serve/internal/pkg/transports/http"
	"gitee.com/cjf8134/bbs_serve/internal/pkg/transports/http/middlewares/auth"
)

func CreateInitControllersFn(tag *TagController, category *CategoryController, index *IndexController, so *session.Options, sess sessions.Store) http.InitControllers {
	return func(r *gin.Engine) {
		r.Use(sessions.Sessions(so.ClientKey, session.SessStore(sess)))
		r.Use(auth.Next())
		//r.Use(auth.CheckSignMiddleware())
		e := r.Group("api/v1/")
		e.GET("tag", tag.List)
		e.POST("category", category.List)
		e.GET("captcha", index.Captcha) // 验证码
		e.POST("email", index.Email)
		e.POST("resetPwd", index.ResetPwd)
		e.POST("thread/list", index.ThreadList)
		e.GET("thread/detail", index.ThreadDetail)
		e.POST("comment/list", index.CommentList)
		e.GET("link/list", index.LinkList)
		e.GET("testexist", index.TestExist)
		e.POST("register", index.Register)
		e.POST("login", index.Login)
		e.GET("totals", index.UserTotal)
		e.GET("score", index.ScoreSort)
		e.POST("search", index.Search)
		e.POST("upload", index.Upload)
		e.Use(auth.JWTAuth())
		e.GET("getuser", index.User)
		e.POST("comment", index.Comment)
		e.POST("thread", index.Thread)
		e.POST("zan", index.Zan)
		e.POST("user/thread", index.UserThread)
		e.POST("avatar", index.Avatar)
		e.POST("pwd", index.Pwd)

	}
}

var ProviderSet = wire.NewSet(NewTagController, NewCategoryController, NewIndexController, CreateInitControllersFn)
